package com.xpu.pms.controller;

import com.xpu.pms.comm.http.Respond;
import com.xpu.pms.mapper.SysMenuRuleMapper;
import com.xpu.pms.entity.SysMenuRuleEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
/**
 * @author 徐立彬
 * @date 2019-11-22
 */
@RestController
@RequestMapping("sys/menurule")
public class SysMenuRuleController {
    @Autowired
    SysMenuRuleMapper sysMenuRuleMapper;
    
    @RequestMapping("/all")
    public List<SysMenuRuleEntity> all() {
        List<SysMenuRuleEntity> list = sysMenuRuleMapper.selectList(new QueryWrapper<>());
        return list;
    }
    
    @RequestMapping("/add")
    public Respond add(@RequestBody SysMenuRuleEntity entity) {
        sysMenuRuleMapper.insert(entity);
        return new Respond();
    }
    
    @RequestMapping("/update")
    public Respond update(@RequestBody SysMenuRuleEntity entity) {
        sysMenuRuleMapper.updateById(entity);
        return new Respond();
    }
    
    @RequestMapping("/del")
    public Respond del(@RequestBody SysMenuRuleEntity entity) {
        sysMenuRuleMapper.deleteById(entity.getId());
        return new Respond();
    }
}
